unit oldOnlineLocate;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TEMPLETFORM, StdCtrls, HemisphereButton, ComCtrls, ExtCtrls,
  Menus, ToolWin, LabelButton, MoveImageButton;

type
  TOnlineLocateForm = class(TMyForm)
    rg: TRadioGroup;
    rb3: TGroupBox;
    dtpStart: TDateTimePicker;
    dtpEnd: TDateTimePicker;
    rb1: TGroupBox;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    MIBtnOK: TMoveImgBtn;
    lbBtnOK: TLabelBtn;
    MIBtnExit: TMoveImgBtn;
    lbBtnExit: TLabelBtn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure rgClick(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure MIBtnOKClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  OnlineLocateForm: TOnlineLocateForm;

implementation

uses DMOldOnlineNote;

{$R *.dfm}

procedure TOnlineLocateForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action:=caFree;
end;

procedure TOnlineLocateForm.rgClick(Sender: TObject);
begin
  inherited;
  if rg.ItemIndex =1 then
     rb3.Visible :=true
  else
     rb3.Visible :=false;
end;

procedure TOnlineLocateForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
  if Key=#13 then
    MIBtnOKClick(MIBtnOK);
end;

procedure TOnlineLocateForm.MIBtnOKClick(Sender: TObject);
var
  strWhere:string;
  strOrder:string;
begin
  inherited;
  case rg.ItemIndex of
  0:  begin
        strWhere:='Where stuNo='+''''+trim(Edit1.Text)+'''';
        strOrder:='Order by stuNo,ID';
      end;
  1:  begin
        strWhere:='Where [upDate] between #'+DateToStr(dtpStart.Date)
          +'# and #'+DateToStr(dtpEnd.Date)+'#';
        strOrder:='Order by [upDate],[upTime],ID';
      end;
  2:  begin
        strWhere:='Where orderlyMan='+''''+Trim(Edit1.Text)+'''';
        strOrder:='Order by orderlyMan,ID';
      end;
  end;
  with DM.ADOQOnlineNote do
  begin
    Active:=false;
    SQL.Strings[1]:=strWhere;
    SQL.Strings[2]:=strOrder;
    Active:=true;
    ModalResult:=mrOK;
  end;
end;

end.
